package com.wuseguang.springcloud.mina;

import org.apache.mina.core.buffer.IoBuffer;
import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.ProtocolEncoderAdapter;
import org.apache.mina.filter.codec.ProtocolEncoderOutput;

/**
 * 编码器将数据直接发出去(不做处理)
 */
public class ByteArrayEncoder extends ProtocolEncoderAdapter {


    @Override
    public void encode(IoSession session, Object message,ProtocolEncoderOutput out) throws Exception {


        out.write(IoBuffer.wrap(message.toString().getBytes()));
        out.flush();
    }

}
